<?php
class defaultModel{
	//属性
	public $connection;
	//方法
	public function __construct($dbhost,$dbuser,$dbpasswd,$dbname){
		$this->connection=@mysql_connect($dbhost,$dbuser,$dbpasswd) or die("数据库链接创建失败:".mysql_error()."<br/>");
		//编码设置
		@mysql_query("set names utf8") or die("设置编码失败:".mysql_error()."<br/>");

		//选择数据库
		@mysql_select_db($dbname) or die("选择数据库失败:".mysql_error()."<br/>");

	}
	public function __destruct(){
		mysql_close($this->connection);
	}
	/*
	getallinfos负责返回defaultController里的index方法里的数据($testarray)
	 */
	public function getallinfos($uid){
		//需要从数据库里获取数据，然后返回出来
		//数据库表查询
		$selectuserinfosql="select * from students where uid='$uid'";
		$result=@mysql_query($selectuserinfosql);
		$row=@mysql_fetch_assoc($result);
		//$row数组里包含的元素名是数据库表的属性名  数组的值就是数据库表元素的值
		// username bieming xuanyan ....
		return $row;
	}

	public function getgerenxuanyan($uid){
		//查询个人宣言信息
		$selectxuanyansql="select xuanyan from students where uid='$uid'";
		$result=@mysql_query($selectxuanyansql);
		$row=@mysql_fetch_assoc($result);
		return $row;//注意这里返回的是数组
	}
	public function getxiangxiziliao($uid){
		//查询详细资料
		$selectxiangxisql="select * from detail where uid='$uid'";
		$result=@mysql_query($selectxiangxisql);
		$row=@mysql_fetch_assoc($result);
		return $row;
	}
	public function getqiuzhiyixiang($uid){
		//查询求职信息
		$selectqiuzhisql="select * from findjob where uid='$uid'";
		$result=@mysql_query($selectqiuzhisql);
		$row=@mysql_fetch_assoc($result);
		return $row;
	}
	public function getjiaoyujingli($uid){
		//查询教育经历
		$selectjiaoyusql="select eduexp from comprehensive where uid='$uid'";
		$result=@mysql_query($selectjiaoyusql);
		$row=@mysql_fetch_assoc($result);
		return $row;
	}
	public function getgongzuojingli($uid){
		//查询工作经历
		$selectgongzuosql="select workexp from comprehensive where uid='$uid'";
		$result=@mysql_query($selectgongzuosql);
		$row=@mysql_fetch_assoc($result);
		return $row;
	}
	public function getzizhizhengshu($uid){
		//查询教育经历
		$selectzhengshusql="select dip from comprehensive where uid='$uid'";
		$result=@mysql_query($selectzhengshusql);
		$row=@mysql_fetch_assoc($result);
		return $row;
	}
	public function getlianxifangshi($uid){
		//查询教育经历
		$selectlianxisql="select conway from comprehensive where uid='$uid'";
		$result=@mysql_query($selectlianxisql);
		$row=@mysql_fetch_assoc($result);
		return $row;
	}
	/**
	 * 加载首界面的导航
	 * @return 导航数组
	 */
	public function getdaohanginfos(){
		//查询下数据库获取导航的信息
		$selectdaohangsql="select title,url from daohang order by id";
		$result=@mysql_query($selectdaohangsql);
		$rowarray=array();
		while($row=@mysql_fetch_assoc($result)){
			$rowarray[$row['title']]=$row["url"];
		}
		//$rowarray数组里包含的元素名是数据库表的属性名(title)，数组的值就是数据库表元素的值(url)
		//shouye xuanyan jiben xiangxi ......
		return $rowarray;
	}
}
?>